<?php foreach($this->result as $row){ 
$cat = $row->findDependentRowSet("Ead_Model_DbTable_Catcurso");     
?>
<div class="content mat-list">
    <div class="tl-img-list"><a class="<?php echo $cat[0]['CTC_CSS']; ?>"></a></div>
    <div class="titulo">
        <?php echo $row->MAT_NOM; ?>
        <?php if($row->MAT_CENE == 1){ ?>
            <img src='<?php echo $this->urlbase; ?>/public/media/images/btn_cene.png' class="user_cene" />
        <?php } ?>
    </div>
    <div class="descricao">
        <?php echo $row->MAT_DESC; ?>
    </div>
    <?php if($row->MAT_CENE == 1 && Zend_Auth::getInstance()->hasIdentity()){ ?> 
        <?php if (Zend_Auth::getInstance()->getStorage()->read()->USU_CENE == 1) { ?>
            <a href="<?php echo $this->urlbase.'/'.$this->controller."/download/id/".$row->MAT_ID; ?>" class="btn-gg"> DOWNLOAD</a>
        <?php } else { ?>
            <a href="javascript:user_cene()" class="btn-gg"> DOWNLOAD</a>
        <?php } ?>
            
    <?php } else { 
        
        $obj = new Ead_Model_DbTable_Material();
        $row = $obj->fetchRow('MAT_ID = ' . $row->MAT_ID);
        $rep = $row->findDependentRowSet("Ead_Model_DbTable_Repositorio"); 
        $aquivoNome = md5($rep[0]['REP_ID'].$rep[0]['REP_DATHOR']).'.*';
        $arquivo = 'public/upload/repositorio/'.$aquivoNome; // caminho absoluto do arquivo
        foreach (glob($arquivo) as $src) {
           $url = $src;
        }
        //$this->urlbase.'/'.$url;//
    ?>
        <a href="<?php echo $this->urlbase.'/'.$this->controller."/download/id/".$row->MAT_ID; ?>" class="btn-gg">DOWNLOAD</a>
    <?php } ?>
</div>
<?php } ?>
